myApp_.onPageInit('my_shoucang',function(page){
	MY_SHOUCANG.shoucang_list();
});

//我的收藏
MY_SHOUCANG = {};

MY_SHOUCANG.__INIT__=function(){
    mainView.router.load({
        url: "src/my_center/my_shoucang/my_shoucang.html"
    });
}

/*
 * 删除收藏
 */
MY_SHOUCANG.shoucang_del = function(goods_id){
	var url = url_('api/V4/shoucang_edit');
	var data = {
		'op': 'del'
		,'goods_id': goods_id
		,'community_id': SESSION.get_community_id()
	};
	var success = function(d){
		if (d.code == 0) {
			my_tips_('取消收藏成功');
			MY_SHOUCANG.shoucang_list();
		} else{
			my_tips_(d.msg);
		}
	}
	request_(url,data,success)
}
/*
 * 收藏列表
 */
MY_SHOUCANG.shoucang_list = function(){
	var url = url_('api/V4/shoucang_list');
	var data = {
		'community_id': SESSION.get_community_id()
	};
	var success = function(d){
		if (d.code == 0) {
			MY_SHOUCANG.fill(d.data);
		} else{
			my_tips_(d.msg);
		}
	}
	request_(url,data,success)
}

//渲染列表
MY_SHOUCANG.fill = function(d){
	$.tpl({
		url: 'src/my_center/my_shoucang/my_shoucang_tpl.html'
		,context: d
		,elem: '#shoucang-content'
	});
}

